package co.edu.usbcali.raju.games.chess.gui;

import co.edu.usbcali.raju.core.AbstractViewPanel;
import co.edu.usbcali.raju.core.graphics.Actor;

public class ChessActor extends Actor {
	
	public static final int JUMP=2;
	int tx;
	int ty;
	int dx=1;
	int dy=1;

	public ChessActor(AbstractViewPanel panel) {
		super(panel);
	}

	public int getTx() {
		return tx;
	}

	public void setTx(int tx) {
		this.tx = tx;
		if(tx>x){
			dx=JUMP;
		}
		if(tx<x){
			dx=-JUMP;
		}
	}

	public int getTy() {
		return ty;
	}

	public void setTy(int ty) {
		this.ty = ty;
		if(ty>y){
			dy=JUMP;
		}
		if(ty<y){
			dy=-JUMP;
		}
	}
	
	
	public void act(){
		if(x!=tx){
			x+=dx;
		}else{
			dx=0;
		}
		if(y!=ty){
			y+=dy;
		}else{
			dy=0;
		}
	}
	
	public boolean isStopped(){
		return (x==tx&&y==ty);
	}

}
